package mn.more.mock.io;

import java.io.IOException;
import java.util.List;

/**
 * general description of a {@link MockModel} reader -- specialized class that can recover persisted mock data from
 * external location.  Implementation class can choose its own method of persistence, including database. However, a
 * get/set method for <code>filename</code> is provided since it is common to saving/reading model data to/from file.
 *
 * @author <a href="mailto:mike.liu@aptechmongolia.edu.mn">Mike Liu</a>
 * @version $Id: MockDataReader.java 5 2008-09-01 12:08:42Z mikeliucc $
 */
public interface MockDataReader {

	/** @return the filename used for reading mock data -- this should be the full path. */
	String getFilename();

	/**
	 * @param filename  the name of the file used for reading mock data, which can either be full path or relative to
	 *                  current classpath.
	 * @param classpath determine whether <code>filename</code> is absolution path or relative to current classpath
	 */
	void setFilename(String filename, boolean classpath) throws IOException;

	/**
	 * write operation is implemented here.  Implementation class will choose its own mechanism for reading model
	 * information, including from database.  This method does not return any data, instead via the {@link
	 * #getModel(String)} method, {@link MockModel} instance can be individually retrieved.
	 */
	void read() throws IOException;

	/** retrieve each {@link MockModel} via its <code>id</code>, which should be unique. */
	MockModel getModel(String id);

	/**
	 * return a list of ids of all the parsed {@link MockModel}.
	 *
	 * @return list of id
	 */
	List<String> getIdList();
}
